
figure(20)
close
figure(20)
hold on
set(gcf, 'Units', 'Inches', 'Position',   [0.6250 2.4306 13.3889 8.1250], 'PaperUnits', 'Inches', 'PaperSize', [8.5, 11])


ResultLabels = RevPetResultsTable_ResultsOnly.Properties.VariableNames;
% PointNum	Region_Label	Melting_P_kbar	Melting_T_C	apparentT_P	OPALM_RMSD	StabilityField	MgNum_Erupted	MgNum_Primary	MgNum_Olivine	Avg_P_kbar	Stdev_P_kbar...
%     Average_T_C	Stdev_T_C	Average_TP_C	Stdev_TP_C	Avg_MgNum	Stdev_MgNum	Average_percentFC	Stdev_percentFC	FieldPTString	DistanceFromField	FailureReason	...
%     GarSpPlagTransitions	DistanceToNearestBoundary	PressureFC	OPAM_RMSD_Erupted	OPM_RMSD_Erupted	MG_CPX	MG_PLAG	OPA_FC	OP_FC	O_FC	totalFC	...
%     SiO2_Primary	TiO2_Primary	Al2O3_Primary	Cr2O3_Primary	FeO_Primary	MnO_Primary	MgO_Primary	CaO_Primary	Na2O_Primary	K2O_Primary	P2O5_Primary	NiO_Primary	H2O_Prim	total_Prim	...
%     MgNum_Prim	NaKNum_Primary	CaOAl2O3wt_Primary	CaOAl2O3mol_Primary	Na2OFeO_Primary	K2OTiO2_Primary	OneMinusMgNum_Primary ....
%     Qtz_Primary	Plag_Primary	Oliv_Primary	Cpx_Primary	Ox_Primary	Or_Primary	Ap_Primary	He_Primary	Cs_Primary	Rb_Primary	Tl_Primary	K_Primary	Li_Primary	Ba_Primary	Pb_Primary	Sr_Primary	Mn_Primary	Co_Primary	Zn_Primary	Cu_Primary	Ni_Primary	Be_Primary	La_Primary	Ce_Primary	Pr_Primary	Nd_Primary	Sm_Primary	Eu_Primary	Gd_Primary	Tb_Primary	Dy_Primary	Ho_Primary	Y_Primary	Er_Primary	Yb_Primary	Lu_Primary	Sc_Primary	Ga_Primary	Cr_Primary	Th_Primary	U_Primary	Zr_Primary	Hf_Primary	Sn_Primary	Mo_Primary	Ti_Primary	V_Primary	Nb_Primary	Ta_Primary	W_Primary	H2O_Primary	Ra_Primary	ThU_Primary	LuHf_Primary	SmNd_Primary	LuSc_Primary	HfNd_Primary	LaSm_Primary	RbSr_Primary	EuSm_Primary	EuGd_Primary	NdZr_Primary	SmYb_Primary	ZrY_Primary	NbY_Primary	GdYb_Primary	ZrYb_Primary	ZrHf_Primary	NbTa_Primary	BaLa_Primary	BaPb_Primary	UPb_Primary	EuAnom_Primary	KU_Primary





IndiciesFig1_X_string = {...
    'Lat' 'Lat'...
    'Lat' 'Lat'...
    'Melting_P_kbar' 'apparentT_P' ...
    };


IndiciesFig1_Y_string = {...
    'Melting_P_kbar'  'Melting_T_C'...
    'K2OTiO2_Primary'   'K2OTiO2_Primary'...
    'OPALM_RMSD'  'OPALM_RMSD'...
    };




% axesMajors = [1200 1400 -6 18; 0 65 10^-2 30; ...
%  -6 18 10^-2 30 ; 1200 1350 10^-2 30;...
%  0 18 10^-2 30; 1200 1350 10^-2 30];

% axesMajors = [1200 1400 -6 18; 0 65 10^-2 2; ...
%  -6 18 10^-2 2 ; 1200 1350 10^-2 2];
axesMajors = [1400 1700 0 40; 0 80 0 .05; ...
    0 40 0 .05 ; 1400 1700 0 .05
    0 4 1400 1700 ; 0 4 1400 1700 ];


axesMajors = [1400 1700 0 45; 0 80 0 0.15; ...
    0 45 0 0.15; 1400 1700 0 0.15
    0 4 1400 1700 ; 0 4 1400 1700 ];

[a,IndiciesFig1_X]=(ismember(IndiciesFig1_X_string,ResultLabels));
[a,IndiciesFig1_Y]=(ismember(IndiciesFig1_Y_string,ResultLabels));




IndiciesX = [IndiciesFig1_X];
IndiciesY = [IndiciesFig1_Y];


numcolumns = 1;
numrows = 2;%round(size(Indicies,2)/numcolumns);


numcolumns = 2;
numrows = 2;

for n = 1:numcolumns.*numrows
    
    yvalue =  IndiciesY(n);
    xvalue = IndiciesX(n);
    
    ytext=  IndiciesFig1_Y_string{n};
    xtext = IndiciesFig1_X_string{n};
    
    
    subaxis(numrows,numcolumns,n,'Spacing',.03,'Margin',0.02,'Padding',0.01,'PaddingLeft',0.04,'PaddingBottom',.04)
    
    
    hold on
    
    %axis(axesMajors(n,:))
    
    
    %arg
    % if ismember(n,[1])
    %     yline(11.5,'k','handlevisibility','off');
    %     yline(25.5,'k','handlevisibility','off');
    % end
    %
    % if ismember(n,[2 3 4])
    %     yline(1.5,'k','handlevisibility','off');
    %     yline(1.5,'k','handlevisibility','off');
    % end
    %
    %
    % if ismember(n,[3 5])
    %     xline(11,'k','handlevisibility','off');
    %     xline(12,'k','handlevisibility','off');
    % end
    
    % if n==1
    % % refline(1/1.5,-1250/1.5)
    % % refline(1/1.5,-1300/1.5)
    % refline(1/1.5,-1350/1.5)
    % refline(1/1.5,-1400/1.5)
    % refline(1/1.5,-1450/1.5)
    % refline(1/1.5,-1500/1.5)
    % refline(1/1.5,-1550/1.5)
    % refline(1/1.5,-1600/1.5)
    % refline(1/1.5,-1650/1.5)
    % refline(1/1.5,-1700/1.5)
    % % refline(1/1.9,-1300/1.9)
    % % refline(1/1.1,-1300/1.1)
    %
    %
    % %refline(1/1.5,-1350/1.5)
    % %axis(axesMajors(n,:))
    % end
    
    
    
    % Original Data that RevPet does not find a Valid Solution
    aaas=1;
    for zztemp = 1:size(Unique_BAD_labels_Rows,1)
        Unique_BAD_label_here = Unique_BAD_labels{zztemp};
        i =find(ismember(CombinedLabel, Unique_BAD_label_here));
        p=ismember(i,BAD_ReverseFC);
        i(p==0)=[];
        
        zz = i(1);
        plot(eval(sprintf('RevPetResultsTable_ResultsOnly.%s(i)',xtext)),eval(sprintf('RevPetResultsTable_ResultsOnly.%s(i)',ytext)),...
            runningMarkers{zz},'LineWidth',1,'MarkerSize',eval(runningSizesBad{1}), 'Color',eval(runningColors_LINE{zz}),'MarkerFaceColor',eval(runningColors_FILL{zz}),'handlevisibility','on');
        
        
        
        aaas=aaas+1;
    end
    
    
    % Original Data with Valid Solutions
    aaas=1;
    for zz = UniqueLabels_Rows'
        i =find(ismember(CombinedLabel, CombinedLabel(zz)));
        p=ismember(i,highlight_ReverseFC);
        i(p==0)=[];
        
        
        plot(eval(sprintf('RevPetResultsTable_ResultsOnly.%s(i)',xtext)),eval(sprintf('RevPetResultsTable_ResultsOnly.%s(i)',ytext)),...
            runningMarkers{zz},'LineWidth',1,'MarkerSize',eval(runningSizes{zz}), 'Color',eval(runningColors_LINE{zz}),'MarkerFaceColor',eval(runningColors_FILL{zz}));
        
        
        aaas=aaas+1;
    end
    
    
    
    
    
    
    if strcmp(xtext,'FCEXTENT')==1
        %set(gca,'xscale','log')
        %set(gca, 'Xtick',[.01 .1 1 10])
        %axis([0 70 10^-2 10^2 ])
        set(gca, 'Xtick',[0:10:65])
    end
    
    if strcmp(ytext,'BEST FIT')==1
        % set(gca,'yscale','log')
        % set(gca, 'Ytick',[.01 .1 1 10 30])
    end
    
    if strcmp(ytext,'Melting_P_kbar')==1
        
        set(gca,'YDir','Reverse')
        %set(gca, 'Ytick',[.01 .1 1 10 100])
    end
    %
    % IndiciesFig1_Y_string = {...
    %      'BEST FIT P'  'NRMSD PM'...
    %      'NRMSD PM'  'NRMSD PM'...
    %     };
    %
    % IndiciesFig1_X_string = {'BEST FIT T' 'FC extent'...
    % 'BEST FIT P' 'BEST FIT Tmp' ...
    % };
    
    % xlabel([xtext])
    % ylabel([ytext])
    
    xlabel(regexprep(ResultLabels(xvalue),'_',' '))
    ylabel(regexprep(ResultLabels(yvalue),'_',' '))
    
    
    
    box on
    %grid on
    
    %set(gca, 'Ytick',[.01 .1 1 10 100])
    ax = gca;
    ax.XAxis.MinorTick = 'on';
    increment = findBestIncrement( ax.XLim(2)- ax.XLim(1),ax.XAxis.TickValues(2) -  ax.XAxis.TickValues(1));
    if ax.XLim(1) == 1200
        increment = 10;
    end
    ax.XAxis.MinorTickValues = ax.XLim(1):increment:ax.XLim(2);
    
    
    %ax.XAxis.MinorTickValues = [.01:.01:.1 .2:.2:1 2:1:10 20:10:100];
    
    
    ax.YAxis.MinorTick = 'on';
    increment = findBestIncrement( ax.YLim(2)- ax.YLim(1),ax.YAxis.TickValues(2) -  ax.YAxis.TickValues(1));
    % if strcmp(Ytext,'Na_2O')
    %     increment = .5;
    % end
    
    %ax.YAxis.MinorTickValues = ax.YLim(1):increment:ax.YLim(2);
    
    
    
    set(gca,'ticklength',1.3*[0.0200    0.0500])
    
    set(gca,'fontsize', 15,'LineWidth',1,'fontname','Times New Roman', 'LineWidth',.7)
    set(gca,'XColor', 'k')
    set(gca,'YColor', 'k')
    %set(gcf,'position',[2.7917 3.4306 9.7361 9.3750])
    % OPTION: uncomment for single (non-subplot plots)
    % legend(TabNames,'location','best')
    % title(FigureTitle)
    % FigureTitle = regexprep(FigureTitle,'\_*','');
    % FigureTitle = regexprep(FigureTitle,'\/','-');
    FigureTitle = 'Latitude';
    set(gcf,'name',regexprep(FigureTitle,'\_*',''))
    %uistack(h2,'bottom')
    % uistack(h1,'bottom')
    
    
    if n==1
        legend({Unique_BAD_labels_leg{:} UniqueLabels_leg{:}})
    end
    
end



%%
figure(22)
close
figure(22)
hold on
set(gcf, 'Units', 'Inches', 'Position',   [0.6250 2.4306 13.3889 8.1250], 'PaperUnits', 'Inches', 'PaperSize', [8.5, 11])



ResultLabels = RevPetResultsTable_ResultsOnly.Properties.VariableNames;
% PointNum	Region_Label	Melting_P_kbar	Melting_T_C	apparentT_P	OPALM_RMSD	StabilityField	MgNum_Erupted	MgNum_Primary	MgNum_Olivine	Avg_P_kbar	Stdev_P_kbar...
%     Average_T_C	Stdev_T_C	Average_TP_C	Stdev_TP_C	Avg_MgNum	Stdev_MgNum	Average_percentFC	Stdev_percentFC	FieldPTString	DistanceFromField	FailureReason	...
%     GarSpPlagTransitions	DistanceToNearestBoundary	PressureFC	OPAM_RMSD_Erupted	OPM_RMSD_Erupted	MG_CPX	MG_PLAG	OPA_FC	OP_FC	O_FC	totalFC	...
%     SiO2_Primary	TiO2_Primary	Al2O3_Primary	Cr2O3_Primary	FeO_Primary	MnO_Primary	MgO_Primary	CaO_Primary	Na2O_Primary	K2O_Primary	P2O5_Primary	NiO_Primary	H2O_Prim	total_Prim	...
%     MgNum_Prim	NaKNum_Primary	CaOAl2O3wt_Primary	CaOAl2O3mol_Primary	Na2OFeO_Primary	K2OTiO2_Primary	OneMinusMgNum_Primary ....
%     Qtz_Primary	Plag_Primary	Oliv_Primary	Cpx_Primary	Ox_Primary	Or_Primary	Ap_Primary	He_Primary	Cs_Primary	Rb_Primary	Tl_Primary	K_Primary	Li_Primary	Ba_Primary	Pb_Primary	Sr_Primary	Mn_Primary	Co_Primary	Zn_Primary	Cu_Primary	Ni_Primary	Be_Primary	La_Primary	Ce_Primary	Pr_Primary	Nd_Primary	Sm_Primary	Eu_Primary	Gd_Primary	Tb_Primary	Dy_Primary	Ho_Primary	Y_Primary	Er_Primary	Yb_Primary	Lu_Primary	Sc_Primary	Ga_Primary	Cr_Primary	Th_Primary	U_Primary	Zr_Primary	Hf_Primary	Sn_Primary	Mo_Primary	Ti_Primary	V_Primary	Nb_Primary	Ta_Primary	W_Primary	H2O_Primary	Ra_Primary	ThU_Primary	LuHf_Primary	SmNd_Primary	LuSc_Primary	HfNd_Primary	LaSm_Primary	RbSr_Primary	EuSm_Primary	EuGd_Primary	NdZr_Primary	SmYb_Primary	ZrY_Primary	NbY_Primary	GdYb_Primary	ZrYb_Primary	ZrHf_Primary	NbTa_Primary	BaLa_Primary	BaPb_Primary	UPb_Primary	EuAnom_Primary	KU_Primary




IndiciesFig1_X_string = {...
    'Long' 'Long'...
     'Long' 'Long'...
    };


IndiciesFig1_Y_string = {...
    'Melting_P_kbar'  'Melting_T_C'...
    'K2OTiO2_Primary'   'K2OTiO2_Primary'...
    };


% axesMajors = [1200 1400 -6 18; 0 65 10^-2 30; ...
%  -6 18 10^-2 30 ; 1200 1350 10^-2 30;...
%  0 18 10^-2 30; 1200 1350 10^-2 30];

% axesMajors = [1200 1400 -6 18; 0 65 10^-2 2; ...
%  -6 18 10^-2 2 ; 1200 1350 10^-2 2];
axesMajors = [1400 1700 0 40; 0 80 0 .05; ...
    0 40 0 .05 ; 1400 1700 0 .05
    0 4 1400 1700 ; 0 4 1400 1700 ];


axesMajors = [1400 1700 0 45; 0 80 0 0.15; ...
    0 45 0 0.15; 1400 1700 0 0.15
    0 4 1400 1700 ; 0 4 1400 1700 ];

[a,IndiciesFig1_X]=(ismember(IndiciesFig1_X_string,ResultLabels));
[a,IndiciesFig1_Y]=(ismember(IndiciesFig1_Y_string,ResultLabels));




IndiciesX = [IndiciesFig1_X];
IndiciesY = [IndiciesFig1_Y];


numcolumns = 1;
numrows = 2;%round(size(Indicies,2)/numcolumns);


for n = 1:numcolumns.*numrows
    
    yvalue =  IndiciesY(n);
    xvalue = IndiciesX(n);
    
    ytext=  IndiciesFig1_Y_string{n};
    xtext = IndiciesFig1_X_string{n};
    
    
    subaxis(numrows,numcolumns,n,'Spacing',.03,'Margin',0.02,'Padding',0.01,'PaddingLeft',0.04,'PaddingBottom',.04)
    
    
    hold on
    
    %axis(axesMajors(n,:))
    
    
    
    
    % Original Data that RevPet does not find a Valid Solution
    aaas=1;
    for zztemp = 1:size(Unique_BAD_labels_Rows,1)
        Unique_BAD_label_here = Unique_BAD_labels{zztemp};
        i =find(ismember(CombinedLabel, Unique_BAD_label_here));
        p=ismember(i,BAD_ReverseFC);
        i(p==0)=[];
        
        zz = i(1);
        plot(eval(sprintf('RevPetResultsTable_ResultsOnly.%s(i)',xtext)),eval(sprintf('RevPetResultsTable_ResultsOnly.%s(i)',ytext)),...
            runningMarkers{zz},'LineWidth',1,'MarkerSize',eval(runningSizesBad{1}), 'Color',eval(runningColors_LINE{zz}),'MarkerFaceColor',eval(runningColors_FILL{zz}),'handlevisibility','on');
        
        
        
        aaas=aaas+1;
    end
    
    
    % Original Data with Valid Solutions
    aaas=1;
    for zz = UniqueLabels_Rows'
        i =find(ismember(CombinedLabel, CombinedLabel(zz)));
        p=ismember(i,highlight_ReverseFC);
        i(p==0)=[];
        
        
        plot(eval(sprintf('RevPetResultsTable_ResultsOnly.%s(i)',xtext)),eval(sprintf('RevPetResultsTable_ResultsOnly.%s(i)',ytext)),...
            runningMarkers{zz},'LineWidth',1,'MarkerSize',eval(runningSizes{zz}), 'Color',eval(runningColors_LINE{zz}),'MarkerFaceColor',eval(runningColors_FILL{zz}));
        
        
        aaas=aaas+1;
    end
    
    
    
    
    if strcmp(xtext,'FCEXTENT')==1
        %set(gca,'xscale','log')
        %set(gca, 'Xtick',[.01 .1 1 10])
        %axis([0 70 10^-2 10^2 ])
        set(gca, 'Xtick',[0:10:65])
    end
    
    if strcmp(ytext,'BEST FIT')==1
        % set(gca,'yscale','log')
        % set(gca, 'Ytick',[.01 .1 1 10 30])
    end
    
    if strcmp(ytext,'Melting_P_kbar')==1
        
        set(gca,'YDir','Reverse')
        %set(gca, 'Ytick',[.01 .1 1 10 100])
    end
    %
    % IndiciesFig1_Y_string = {...
    %      'BEST FIT P'  'NRMSD PM'...
    %      'NRMSD PM'  'NRMSD PM'...
    %     };
    %
    % IndiciesFig1_X_string = {'BEST FIT T' 'FC extent'...
    % 'BEST FIT P' 'BEST FIT Tmp' ...
    % };
    
    % xlabel([xtext])
    % ylabel([ytext])
    
    xlabel(regexprep(ResultLabels(xvalue),'_',' '))
    ylabel(regexprep(ResultLabels(yvalue),'_',' '))
    
    
    
    box on
    %grid on
    
    %set(gca, 'Ytick',[.01 .1 1 10 100])
    ax = gca;
    ax.XAxis.MinorTick = 'on';
    increment = findBestIncrement( ax.XLim(2)- ax.XLim(1),ax.XAxis.TickValues(2) -  ax.XAxis.TickValues(1));
    if ax.XLim(1) == 1200
        increment = 10;
    end
    ax.XAxis.MinorTickValues = ax.XLim(1):increment:ax.XLim(2);
    
    
    %ax.XAxis.MinorTickValues = [.01:.01:.1 .2:.2:1 2:1:10 20:10:100];
    
    
    ax.YAxis.MinorTick = 'on';
    increment = findBestIncrement( ax.YLim(2)- ax.YLim(1),ax.YAxis.TickValues(2) -  ax.YAxis.TickValues(1));
    
    if n==4
        legend(UniqueLabels{:})
    end
    
    
    set(gca,'ticklength',1.3*[0.0200    0.0500])
    
    set(gca,'fontsize', 15,'LineWidth',1,'fontname','Times New Roman', 'LineWidth',.7)
    set(gca,'XColor', 'k')
    set(gca,'YColor', 'k')
    %set(gcf,'position',[2.7917 3.4306 9.7361 9.3750])
    % OPTION: uncomment for single (non-subplot plots)
    % legend(TabNames,'location','best')
    % title(FigureTitle)
    % FigureTitle = regexprep(FigureTitle,'\_*','');
    % FigureTitle = regexprep(FigureTitle,'\/','-');
    FigureTitle = 'Longitude';
    set(gcf,'name',regexprep(FigureTitle,'\_*',''))
    %uistack(h2,'bottom')
    % uistack(h1,'bottom')
    
    if n==1
        legend({Unique_BAD_labels_leg{:} UniqueLabels_leg{:}})
    end
    
    
end






%%
figure(25)
close
figure(25)
hold on
set(gcf, 'Units', 'Inches', 'Position',   [0.6250 2.4306 13.3889 8.1250], 'PaperUnits', 'Inches', 'PaperSize', [8.5, 11])



ResultLabels = RevPetResultsTable_ResultsOnly.Properties.VariableNames;
% PointNum	Region_Label	Melting_P_kbar	Melting_T_C	apparentT_P	OPALM_RMSD	StabilityField	MgNum_Erupted	MgNum_Primary	MgNum_Olivine	Avg_P_kbar	Stdev_P_kbar...
%     Average_T_C	Stdev_T_C	Average_TP_C	Stdev_TP_C	Avg_MgNum	Stdev_MgNum	Average_percentFC	Stdev_percentFC	FieldPTString	DistanceFromField	FailureReason	...
%     GarSpPlagTransitions	DistanceToNearestBoundary	PressureFC	OPAM_RMSD_Erupted	OPM_RMSD_Erupted	MG_CPX	MG_PLAG	OPA_FC	OP_FC	O_FC	totalFC	...
%     SiO2_Primary	TiO2_Primary	Al2O3_Primary	Cr2O3_Primary	FeO_Primary	MnO_Primary	MgO_Primary	CaO_Primary	Na2O_Primary	K2O_Primary	P2O5_Primary	NiO_Primary	H2O_Prim	total_Prim	...
%     MgNum_Prim	NaKNum_Primary	CaOAl2O3wt_Primary	CaOAl2O3mol_Primary	Na2OFeO_Primary	K2OTiO2_Primary	OneMinusMgNum_Primary ....
%     Qtz_Primary	Plag_Primary	Oliv_Primary	Cpx_Primary	Ox_Primary	Or_Primary	Ap_Primary	He_Primary	Cs_Primary	Rb_Primary	Tl_Primary	K_Primary	Li_Primary	Ba_Primary	Pb_Primary	Sr_Primary	Mn_Primary	Co_Primary	Zn_Primary	Cu_Primary	Ni_Primary	Be_Primary	La_Primary	Ce_Primary	Pr_Primary	Nd_Primary	Sm_Primary	Eu_Primary	Gd_Primary	Tb_Primary	Dy_Primary	Ho_Primary	Y_Primary	Er_Primary	Yb_Primary	Lu_Primary	Sc_Primary	Ga_Primary	Cr_Primary	Th_Primary	U_Primary	Zr_Primary	Hf_Primary	Sn_Primary	Mo_Primary	Ti_Primary	V_Primary	Nb_Primary	Ta_Primary	W_Primary	H2O_Primary	Ra_Primary	ThU_Primary	LuHf_Primary	SmNd_Primary	LuSc_Primary	HfNd_Primary	LaSm_Primary	RbSr_Primary	EuSm_Primary	EuGd_Primary	NdZr_Primary	SmYb_Primary	ZrY_Primary	NbY_Primary	GdYb_Primary	ZrYb_Primary	ZrHf_Primary	NbTa_Primary	BaLa_Primary	BaPb_Primary	UPb_Primary	EuAnom_Primary	KU_Primary





IndiciesFig1_X_string = {...
    'Lat' 'Lat'...
    'MgO_Primary' 'FeO_Primary' ...
    'Melting_P_kbar' 'apparentT_P' ...
    };


IndiciesFig1_Y_string = {...
    'apparentT_P'  'apparentT_P'...
    'apparentT_P'   'apparentT_P'...
    'OPALM_RMSD'  'OPALM_RMSD'...
    };


% axesMajors = [1200 1400 -6 18; 0 65 10^-2 30; ...
%  -6 18 10^-2 30 ; 1200 1350 10^-2 30;...
%  0 18 10^-2 30; 1200 1350 10^-2 30];

% axesMajors = [1200 1400 -6 18; 0 65 10^-2 2; ...
%  -6 18 10^-2 2 ; 1200 1350 10^-2 2];
axesMajors = [1400 1700 0 40; 0 80 0 .05; ...
    0 40 0 .05 ; 1400 1700 0 .05
    0 4 1400 1700 ; 0 4 1400 1700 ];


axesMajors = [1400 1700 0 45; 0 80 0 0.15; ...
    0 45 0 0.15; 1400 1700 0 0.15
    0 4 1400 1700 ; 0 4 1400 1700 ];

[a,IndiciesFig1_X]=(ismember(IndiciesFig1_X_string,ResultLabels));
[a,IndiciesFig1_Y]=(ismember(IndiciesFig1_Y_string,ResultLabels));


IndiciesX = [IndiciesFig1_X];
IndiciesY = [IndiciesFig1_Y];


numcolumns = 1;
numrows = 1;%round(size(Indicies,2)/numcolumns);




for n = 1:numcolumns.*numrows
    
    yvalue =  IndiciesY(n);
    xvalue = IndiciesX(n);
    
    ytext=  IndiciesFig1_Y_string{n};
    xtext = IndiciesFig1_X_string{n};
    
    
    subaxis(numrows,numcolumns,n,'Spacing',.03,'Margin',0.02,'Padding',0.02,'PaddingLeft',0.05,'PaddingBottom',.05)
    
    
    hold on
    
    
    LatNumbers = RevPetResultsTable_ResultsOnly.Lat;
    LongNumbers = RevPetResultsTable_ResultsOnly.Long;
    plumecenterindex=1;
    for i = 1:size(LatNumbers,1)
        Xdistance(i) = lldistkm([LatNumbers(i),LongNumbers(i)],[LatNumbers(plumecenterindex),LongNumbers(plumecenterindex)]);
    end
    
    Xdistance=Xdistance';
    
    
    
    % Original Data that RevPet does not find a Valid Solution
    aaas=1;
    for zztemp = 1:size(Unique_BAD_labels_Rows,1)
        Unique_BAD_label_here = Unique_BAD_labels{zztemp};
        i =find(ismember(CombinedLabel, Unique_BAD_label_here));
        p=ismember(i,BAD_ReverseFC);
        i(p==0)=[];
        
        zz = i(1);
        plot(Xdistance(i),eval(sprintf('RevPetResultsTable_ResultsOnly.%s(i)',ytext)),...
            runningMarkers{zz},'LineWidth',1,'MarkerSize',eval(runningSizesBad{1}), 'Color',eval(runningColors_LINE{zz}),'MarkerFaceColor',eval(runningColors_FILL{zz}),'handlevisibility','on');
        
        
        
        aaas=aaas+1;
    end
    
    
    % Original Data with Valid Solutions
    aaas=1;
    for zz = UniqueLabels_Rows'
        i =find(ismember(CombinedLabel, CombinedLabel(zz)));
        p=ismember(i,highlight_ReverseFC);
        i(p==0)=[];
        
        plot(Xdistance(i),eval(sprintf('RevPetResultsTable_ResultsOnly.%s(i)',ytext)),...
            runningMarkers{zz},'LineWidth',1,'MarkerSize',eval(runningSizes{zz}), 'Color',eval(runningColors_LINE{zz}),'MarkerFaceColor',eval(runningColors_FILL{zz}));
        
        
        aaas=aaas+1;
    end
    
    
    
    
    
    
    %
    %         aaas=1;
    %         for zz = UniqueLabels_Rows'
    %             i =find(ismember(CombinedLabel, CombinedLabel(zz)));
    %
    %             plot(Xdistance(i),eval(sprintf('RevPetResultsTable_ResultsOnly.%s(i)',ytext)),...
    %                 runningMarkers{zz},'LineWidth',1,'MarkerSize',5, 'Color',eval(runningColors_LINE{zz}),'MarkerFaceColor',eval(runningColors_FILL{zz}),'handlevisibility','off');
    %
    %
    %             p=ismember(i,highlight_ReverseFC);
    %             i(p==0)=[];
    %
    %             plot(Xdistance(i),eval(sprintf('RevPetResultsTable_ResultsOnly.%s(i)',ytext)),...
    %                 runningMarkers{zz},'LineWidth',1,'MarkerSize',eval(runningSizes{zz}), 'Color',eval(runningColors_LINE{zz}),'MarkerFaceColor',eval(runningColors_FILL{zz}));
    %
    %
    %             aaas=aaas+1;
    %         end
    %
    
    
    
    
    
    TempBackground = 1290;
    TempPlume = 1400;
    deltaTmax=TempPlume-TempBackground;
    x=[0:1:1500];%km
    t=150;%million years
    modelinfo = sprintf('Thermal Model with Plume:%d%sC, Mantle:%d%sC',TempPlume,char(176),TempBackground,char(176));
    % legendkey{end+1} = modelinfo;
    
    
    distance = [440 1500 2891]; %km
    upwellingrate=1.5;%cm/yr
    % upwellingrate=0.5;%cm/yr for Afar?
    upwellingrate=upwellingrate*10;%km/ma
    t = distance./upwellingrate
    
    
    
    kappa = 31.5; %km2/million year
    for k = 1:size(t,2)
        deltaT=TempPlume-deltaTmax.*erf(x./(4.*kappa.*t(k)).^0.5);
        plot(x, deltaT,'k-','LineWidth',3);
    end
    
    
    
    xlabel('Distance from plume center (km)')
    ylabel([ResultLabels(yvalue)])
    set(gca,'ticklength',2*[0.0200    0.0500])
    set(gca,'fontsize', 13,'LineWidth',0.7,'FontName', 'Times New Roman')
    
    
    
    box on
    %grid on
    
    %set(gca, 'Ytick',[.01 .1 1 10 100])
    ax = gca;
    ax.XAxis.MinorTick = 'on';
    increment = findBestIncrement( ax.XLim(2)- ax.XLim(1),ax.XAxis.TickValues(2) -  ax.XAxis.TickValues(1));
    if ax.XLim(1) == 1200
        increment = 10;
    end
    ax.XAxis.MinorTickValues = ax.XLim(1):increment:ax.XLim(2);
    
    
    %ax.XAxis.MinorTickValues = [.01:.01:.1 .2:.2:1 2:1:10 20:10:100];
    
    
    ax.YAxis.MinorTick = 'on';
    increment = findBestIncrement( ax.YLim(2)- ax.YLim(1),ax.YAxis.TickValues(2) -  ax.YAxis.TickValues(1));
    % if strcmp(Ytext,'Na_2O')
    %     increment = .5;
    % end
    
    %ax.YAxis.MinorTickValues = ax.YLim(1):increment:ax.YLim(2);
    
    if n ==1
        legend({Unique_BAD_labels_leg{:} UniqueLabels_leg{:} modelinfo},'Autoupdate','off')
    end
    
    
    
    set(gca,'ticklength',1.3*[0.0200    0.0500])
    
    set(gca,'fontsize', 17,'fontname','Times New Roman', 'LineWidth',.7)
    set(gca,'XColor', 'k')
    set(gca,'YColor', 'k')
    %set(gcf,'position',[2.7917 3.4306 9.7361 9.3750])
    % OPTION: uncomment for single (non-subplot plots)
    % legend(TabNames,'location','best')
    % title(FigureTitle)
    % FigureTitle = regexprep(FigureTitle,'\_*','');
    % FigureTitle = regexprep(FigureTitle,'\/','-');
    FigureTitle = 'ThermalModel';
    set(gcf,'name',regexprep(FigureTitle,'\_*',''))
    %uistack(h2,'bottom')
    % uistack(h1,'bottom')
    
end





return
%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%cab is a "close all but" function, so tell it the figuers you want to keep (once you have the axes the way you want)
%and then run this section to save the figures e.g.,
cab 1 25
savefigsPDF(worksheetName2Save,subfolder)

